//===============================================================================
// Microsoft Architecture Strategy Team
// LitwareHR - SaaS Sample Application
//===============================================================================
// Copyright  Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================



using System;
using System.Collections.Generic;
using Shp.Runtime.Contract;
using SqlDataModel = Shp.Runtime.DataModel.Sql;
using SitkaDataModel = Shp.Runtime.DataModel.Sitka;

namespace Shp.Runtime.Services
{
    static public class DatamodelLogic
    {        
        private static SitkaDataModel.BaseDataModel _dataModel = new SitkaDataModel.BaseDataModel();

        static public StringPair[][] GetInstanceList(string tenantAlias, string entityDefName, Guid[] listToRetrieve)
        {            
            return _dataModel.GetInstanceList(SystemLogic.GetTenantId(tenantAlias), entityDefName, listToRetrieve);
        }

        static public StringPair[] GetViewDefFields(string tenantAlias, string viewDefName)
        {
            return _dataModel.GetViewDefFields(tenantAlias, viewDefName);
        }

        static public StringPair[] GetViewDefFields(string tenantAlias, Guid viewDefId)
        {
            return _dataModel.GetViewDefFields(tenantAlias, viewDefId);
        }

        static public EntityField[] GetEntityDefFields(string tenantAlias, string entityDefName)
        {
            return _dataModel.GetEntityDefFields(tenantAlias, entityDefName);
        }

        static public Dictionary<Guid, string> GetEntityDefList()
        {
            return _dataModel.GetEntityDefList();
        }

        static public Dictionary<Guid, string> GetViewDefList()
        {
            return _dataModel.GetViewDefList();
        }

        static public GuidStringPair[] GetTypeList()
        {
            return _dataModel.GetTypeList();
        }

        static public void UpdateViewDef(Guid tenantId, Guid viewDefId, StringPair[] fields)
        {
	         _dataModel.UpdateViewDef(tenantId, viewDefId, fields);            
        }

        static public void UpdateEntityDef(Guid tenantId, Guid entityDefId, EntityField[] fields)
        {
            _dataModel.UpdateEntityDef(tenantId, entityDefId, fields);
        }           

        static public Guid AddInstance(Guid tenantId, string entityDefName, EntityField[] fields)
        {            
            return _dataModel.AddInstance(tenantId, entityDefName, fields);
        }
    }
}
